<?php
class UserAction extends AclAction {
    public function add(){
        $this->display();
    }
    public function insert(){
    	 // header('Content-Type:text/html; charset=utf-8');
        $user=M("user");
        $user->create();
        $user->password=md5($_POST['password']);
        if($user->add()){
        	$this->success("添加成功",U(show));
        }else{
        	$this->error("添加失败");
        }
    }

    public function show(){
    	$user=M("user");
    	$rows=$user->select();
    	$this->assign("rows",$rows);
    	$this->display();
    }

    public function delete(){
    	$user=M("user");
    	if($user->where("id={$_GET['id']}")->delete()){
    		$this->success("删除成功！",U(show));
    	}else{
    		$this->error("删除失败！");
    	}
    }

    public function edit(){
    	$this->assign("get",$_GET);
    	$this->display();
    }
    
    public function update(){
       $user=M("user");
       $user->create();
       if($user->where("id={$_POST['id']}")->save()){
       	    $this->success("修改成功",U(show));
       }else{
       	     $this->error("修改失败");
       }
    }
}